package com.tom.demo.web.product;

import com.tom.demo.common.entity.Trademark;
import com.tom.demo.common.response.Result;
import com.tom.demo.service.product.TrademarkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "品牌管理")
@RestController
@RequestMapping("/product")
public class TrademarkController {

    @Resource
    private TrademarkService trademarkService;

    @PostMapping(path = {"/trademark/list"})
    @ApiOperation(value = "获取品牌信息列表")
    public Result list(@RequestParam(value = "page",defaultValue = "1")Integer page,
                       @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize){

        return trademarkService.list(page,pageSize);
    }

    @PostMapping(path = {"/trademark/save"})
    @ApiOperation(value = "新增品牌信息")
    public Result save(@RequestBody @Validated Trademark trademark){

        return trademarkService.save(trademark);
    }

    @PutMapping(path = {"/trademark/update"})
    @ApiOperation(value = "修改品牌信息")
    public Result update(@RequestBody @Validated Trademark trademark){

        return trademarkService.update(trademark);
    }

    @DeleteMapping(path = {"/trademark/delete/{id}"})
    @ApiOperation(value = "删除品牌信息")
    public Result delete(@PathVariable(value = "id")String id){

        return trademarkService.delete(id);
    }

    @GetMapping(path = {"/trademark/findById/{id}"})
    @ApiOperation(value = "获取品牌信息")
    public Result findById(@PathVariable(value = "id")String id){

        return trademarkService.findById(id);
    }
}
